package com.concurrence;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


public class HashMapUnSafeDemo {

    public static void main(String[] args) throws InterruptedException {
        final Map map = new HashMap(2);
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                new Thread(() ->
                        map.put(UUID.randomUUID().toString(), "")
                        , "put" + i).start();
            }
        });
        thread.start();
        thread.join();
        System.out.println(map.size());
    }
}
